// index.js
// 获取应用实例
import device from '../../api/deviceInfo'

const app = getApp()
Page({
  data: {
    deviceList:[],
    deviceId:'',
  },

  onLoad() {
    device.getDeviceList().then(res=>{
      this.setData({
        deviceList:res.data.data
      })
    })
  },
  navigate(e){
     var data  = e.currentTarget.dataset
     var url
     console.log(data);
    if(data.devicetype === '板载灯'){
      url = `../singleLed/singleLed?deviceId=${data.deviceid}&online=${data.online}`
    }
    if(data.devicetype === '温湿度检测模块'){
      url = `../tempAndHumidity/tempAndHumidity?deviceId=${data.deviceid}&online=${data.online}`
    }
    if(data.devicetype === '红外人体检测模块'){
      url = `../infrared/infrared?deviceId=${data.deviceid}&online=${data.online}`
    }
    wx.redirectTo({
      url: `${url}`
    })
  }
})